/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaFinSaida.java
 *
 * Created on 24/05/2011, 23:14:41
 */
package asfabdesk.apresentacao;

import asfabdesk.dominio.CentroDeCusto;
import asfabdesk.dominio.Data;
import asfabdesk.dominio.DepositoFinanceiro;
import asfabdesk.dominio.HistoricoFinanceiro;
import asfabdesk.dominio.ItemSaida;
import asfabdesk.dominio.Moeda;
import asfabdesk.dominio.SaidaFinanceira;
import asfabdesk.dominio.TipoSaida;
import asfabdesk.presistencia.DAO;
import asfabdesk.util.Util;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Marco Aurelio
 */
public class TelaFinSaida extends javax.swing.JInternalFrame {

    private List<ItemSaida> itens = new ArrayList();
    private double valorTotal = 0;
    private SaidaFinanceira saida = new SaidaFinanceira();
    Date data = new Date();
    DepositoFinanceiro deposito = new DepositoFinanceiro();

    /** Creates new form TelaFinSaida */
    public TelaFinSaida() throws SQLException, ParseException {
        initComponents();
        configurarTela();
    }

    public TelaFinSaida(SaidaFinanceira saida, List<ItemSaida> itens) throws SQLException {
        initComponents();
        this.saida = saida;
        this.itens = itens;
        configurarTelaEdt();
    }

    public void configurarTela() throws SQLException, ParseException {
        configurarComboTipoSaida();
        txtSituacao.setText("Nova");
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(data);
        txtData.setText(dataString);
        try {
            data = new Data().ConverteDataHoraStringDate(dataString);
        } catch (ParseException ex) {
            Logger.getLogger(TelaAssociadoEdt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void configurarTelaEdt() throws SQLException {
        configurarComboTipoSaida();
        povoarCamposEdicao();

        if (saida.getSituacao() == 1) {
            configurarPosLancamento();
        } else if (saida.getSituacao() == 2) {
            configurarPosConfirmacao();
        } else if (saida.getSituacao() == 3) {
            configurarPosCancel();
        }
        atualizarTabela();
    }

    public void povoarCamposEdicao() {
        txtNumero.setText(String.valueOf(saida.getId()));
        txtData.setText(new Data().ConverteDataDateStringBra(saida.getDataSaida()));
        comboTipoSaida.setSelectedItem(saida.getTipoSaida().getDescricao());
        txtDeposito.setText(saida.getTipoSaida().getDepositoFinanceiro().getDescricao());
        txtObservacao.setText(saida.getObservacao());
    }

    public void povoarSaida() {
        try {
            saida.setDataSaida(new Data().ConverteDataStringDate(txtData.getText()));
            saida.setTipoSaida((TipoSaida) new DAO().localizar(TipoSaida.class, "TipoSaidaPorNome", comboTipoSaida.getSelectedItem().toString()));
            saida.setObservacao(txtObservacao.getText());
            saida.setValorTotal(valorTotal);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void lancarSaida() {
        if (verificaCampos()) {
            try {
                povoarSaida();
                saida.setDataLancamento(data);
                saida.setSituacao(1);
                saida.setUsuarioLancamento(TelaLogin.usuario);
                saida = new DAO().salvar(saida);
                salvarItens(saida, itens);
                JOptionPane.showMessageDialog(null, "Lançamento Realizado com Sucesso. Número da Saída: " + saida.getId().toString(), "Sucesso !", 1);
                configurarPosLancamento();
            } catch (Exception e) {
                new DAO().rollback();
                JOptionPane.showMessageDialog(null, "Ocorreu um Problema durante o lançamento desta Saída. Tente novamente.", "Ops", 2);
                e.printStackTrace();
            }
        }
    }

    public void confirmarSaida() {
        if (verificaCampos()) {
            if (saida.getValorTotal() <= deposito.getFundoMonetario()) {
                try {
                    povoarSaida();
                    saida.setDataConfirmacao(data);
                    saida.setSituacao(2);
                    saida.setUsuarioConfirmacao(TelaLogin.usuario);
                    saida.setFundoDepPre(deposito.getFundoMonetario());
                    saida.setFundoDepPos(saida.getFundoDepPre() - saida.getValorTotal());
                    saida = new DAO().salvar(saida);
                    salvarItens(saida, itens);
                    atualizarFundoModetarioDeposito(saida, false);
                    salvarHistorico(saida, 2, 4);
                    JOptionPane.showMessageDialog(null, "Saída " + saida.getId().toString() + " Confirmada com Sucesso!", "Confirmada !", 1);
                    configurarPosConfirmacao();
                } catch (Exception e) {
                    new DAO().rollback();
                    JOptionPane.showMessageDialog(null, "Ocorreu um Problema durante a confirmação desta Saída. Tente novamente.", "Ops", 2);
                    e.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Este Depósito Financeiro não possui saldo suficiente para executar esta Saída!", "Saldo Insuficiente!", 2);
            }

        }
    }

    public void estornarSaida() {
        if (saida.getSituacao() == 2) {
            try {
                saida.setSituacao(1);
                saida.setDataEstorno(data);
                saida.setUsuarioEstorno(TelaLogin.usuario);
                saida.setFundoDepPre(deposito.getFundoMonetario());
                saida.setFundoDepPos(saida.getFundoDepPre() + saida.getValorTotal());
                atualizarFundoModetarioDeposito(saida, true);
                salvarHistorico(saida, 1, 5);
                JOptionPane.showMessageDialog(null, "Saída " + saida.getId().toString() + " Estornada com Sucesso!", "Estornada !", 1);
                configurarPosEstorno();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void cancelarSaida() {
        try {
            saida.setSituacao(3);
            saida.setDataCancelamento(data);
            saida.setUsuarioCancelamento(TelaLogin.usuario);
            saida.setFundoDepPre(deposito.getFundoMonetario());
            saida.setFundoDepPos(saida.getFundoDepPre() + saida.getValorTotal());
            atualizarFundoModetarioDeposito(saida, true);
            salvarHistorico(saida, 1, 6);
            JOptionPane.showMessageDialog(null, "Saída " + saida.getId().toString() + " Cancelada com Sucesso!", "Cancelada !", 1);
            configurarPosCancel();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void adicionarItem() {
        if (comboCentroCusto.getSelectedItem() == null || txtValor.getText().equals("") || txtValor.getText().equals("0,00") || txtValor.getText().equals("0")) {
            JOptionPane.showMessageDialog(null, "Ops, verifique o Centro de Custo e/ou o Valor não pode ser zerado.", "Ops", 2);
        } else {
            try {
                CentroDeCusto centro = new DAO().localizar(CentroDeCusto.class, "CentroCustoPorNome", comboCentroCusto.getSelectedItem().toString());
                ItemSaida item = new ItemSaida();
                item.setCentroCusto(centro);
                if (txtDataVencimento.getText().equals("  /  /    ")) {
                } else {
                    item.setDataVencimento(new Data().ConverteDataHoraStringDate(txtDataVencimento.getText()));
                }
                if (txtDataPgt.getText().equals("  /  /    ")) {
                } else {
                    item.setDataPgt(new Data().ConverteDataHoraStringDate(txtDataPgt.getText()));
                }
                item.setValorIten(new Util().getNumero(txtValor.getText()));
                itens.add(item);
                atualizarTabela();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void removerItem() {
        ItemSaida item = (((ModeloItens) tabelaItens.getModel()).getItemSaida(tabelaItens.getSelectedRow()));
        int resposta = 10;
        resposta = JOptionPane.showConfirmDialog(null, "Realmente deseja remover o Centro de Custo : " + item.getCentroCusto().getDescricao() + " desta lista de Saidas?", "Excluir da lista?", 0);
        if (resposta == 0 && item.getId() != null) { //caso a entrada já esteja salva , é necessário retirar o ítem do BD e Alterar novamenta a Entrada (Re-lançar)
            try {
                new DAO().remover(item);
                atualizarTabela();
                itens.remove(item);
                JOptionPane.showMessageDialog(null, "Item removido da lista com Sucesso!", "Item Removido", 1);
                lancarSaida();
            } catch (Exception e) {
                System.out.print(e.getMessage());
            }
        } else if (resposta == 0 && item.getId() == null) {
            itens.remove(item);
            JOptionPane.showMessageDialog(null, "Item removido da lista com Sucesso!", "Item Removido", 1);
            atualizarTabela();
        }
    }

    public void editarItem() {
        ItemSaida item = (((ModeloItens) tabelaItens.getModel()).getItemSaida(tabelaItens.getSelectedRow()));
        comboCentroCusto.setSelectedItem(item.getCentroCusto());
        txtDataVencimento.setText(new Data().ConverteDataDateStringBra(item.getDataVencimento()));
        txtDataPgt.setText(new Data().ConverteDataDateStringBra(item.getDataPgt()));
        txtValor.setText(String.valueOf(valorTotal));
    }

    public void salvarItens(SaidaFinanceira saida, List<ItemSaida> lista) {
        DAO dao = new DAO();
        for (int i = 0; i < lista.size(); i++) {
            lista.get(i).setSaida(saida);
            lista.set(i, new DAO().salvar(lista.get(i)));
        }
        atualizarTabela();
    }

    public void configurarPosLancamento() {
        btnConfirmar.setEnabled(true);
        btnCancelar.setEnabled(false);
        txtNumero.setText(saida.getId().toString());
        txtSituacao.setText("Lançada");
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(saida.getDataLancamento());
        txtDataLancamento.setText(dataString);
        txtLancamentoPor.setText(saida.getUsuarioLancamento().getNome() + " " + saida.getUsuarioLancamento().getSobreNome());
    }

    public void configurarPosConfirmacao() {
        btnConfirmar.setEnabled(false);
        btnCancelar.setEnabled(true);
        btnEstornar.setEnabled(true);
        btnLancar.setEnabled(false);
        btnAdicionar.setEnabled(false);
        btnRemover.setEnabled(false);
        btnEditar.setEnabled(false);
        txtSituacao.setText("Confirmada");
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(saida.getDataConfirmacao());
        txtDataConfirmacao.setText(dataString);
        txtConfirmadoPor.setText(saida.getUsuarioConfirmacao().getNome() + " " + saida.getUsuarioConfirmacao().getSobreNome());
        txtObservacao.setEditable(false);
        txtData.setEditable(false);
    }

    public void configurarPosEstorno() {
        btnConfirmar.setEnabled(false);
        btnCancelar.setEnabled(false);
        btnEstornar.setEnabled(false);
        btnLancar.setEnabled(true);
        txtSituacao.setText("Lançada");
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(saida.getDataEstorno());
        txtDataEstorno.setText(dataString);
        txtEstornadoPor.setText(saida.getUsuarioEstorno().getNome() + " " + saida.getUsuarioEstorno().getSobreNome());
        txtDataConfirmacao.setText("  /  /    ");
        txtConfirmadoPor.setText("");
        txtObservacao.setEditable(false);
        txtData.setEditable(false);
    }

    public void configurarPosCancel() {
        btnConfirmar.setEnabled(false);
        btnCancelar.setEnabled(false);
        btnEstornar.setEnabled(false);
        btnLancar.setEnabled(false);
        btnAdicionar.setEnabled(false);
        btnEditar.setEnabled(false);
        btnRemover.setEnabled(false);
        txtSituacao.setText("Cancelada");
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(saida.getDataEstorno());
        txtDataCancelamento.setText(dataString);
        txtCanceladoPor.setText(saida.getUsuarioCancelamento().getNome() + " " + saida.getUsuarioCancelamento().getSobreNome());
        txtObservacao.setEditable(false);
        txtData.setEditable(false);
    }

    public void salvarHistorico(SaidaFinanceira said, int tipo, int motivo) {
        HistoricoFinanceiro historico = new HistoricoFinanceiro();
        historico.setSaida(said);
        historico.setTipo(tipo);
        historico.setMotivo(motivo);
        historico.setDepositoFinanceiro(said.getTipoSaida().getDepositoFinanceiro());
        new DAO().salvar(historico);
    }

    public void atualizarFundoModetarioDeposito(SaidaFinanceira saida, boolean estorno) {
        if (estorno) {
            deposito.setFundoMonetario(deposito.getFundoMonetario() + saida.getValorTotal());
        } else {
            deposito.setFundoMonetario(deposito.getFundoMonetario() - saida.getValorTotal());
        }
        new DAO().salvar(deposito);
    }

    public boolean verificaCampos() {
        boolean retorno = true;
        StringBuffer campos = new StringBuffer();
        String campo;

        if (comboTipoSaida.getSelectedItem().toString().equals("")) {
            campo = "(Tipo de Saída) ";
            campos.append(campo);
            retorno = false;
        }
        if (retorno == false) {
            JOptionPane.showMessageDialog(null, "Ops, você não preencheu o(s) seguinte(s) campo(s) obrigatório(s): " + '\n' + campos, "Campos Obrigatórios.", 2);
        }
        return retorno;
    }

    public void configurarComboTipoSaida() throws SQLException {
        java.util.List tipos = (new DAO()).listar(TipoSaida.class);
        for (int i = 0; i < tipos.size(); i++) {
            String descricao = ((TipoSaida) tipos.get(i)).getDescricao();
            comboTipoSaida.addItem(descricao);
        }
        comboTipoSaida.addItem("");
        comboTipoSaida.setSelectedItem("");
    }

    public void configurarComboCentroCusto(TipoSaida tipo) throws SQLException {
        comboCentroCusto.removeAllItems();
        java.util.List centros = (new DAO()).listar(CentroDeCusto.class, "CentroCustoPorTipoSaida", tipo);
        for (int i = 0; i < centros.size(); i++) {
            String descricao = ((CentroDeCusto) centros.get(i)).getDescricao();
            comboCentroCusto.addItem(descricao);
        }
        comboCentroCusto.addItem("");
        comboCentroCusto.setSelectedItem("");
    }

    public void acaoComboTipoSaida() throws SQLException {
        if (comboTipoSaida.getSelectedItem().equals("")) {
            txtDeposito.setText("");
            comboCentroCusto.removeAllItems();
            btnAdicionar.setEnabled(false);
        } else {
            TipoSaida tipoSaida = new DAO().localizar(TipoSaida.class, "TipoSaidaPorNome", comboTipoSaida.getSelectedItem().toString());
            deposito = tipoSaida.getDepositoFinanceiro();
            txtDeposito.setText(deposito.getDescricao());
            configurarComboCentroCusto(tipoSaida);
            btnAdicionar.setEnabled(true);
        }
    }

    public void resetarVariaveis() {
        comboCentroCusto.setSelectedItem("");
        txtValor.setText("0,00");
        try {
            txtDataVencimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("  /  /    ")));
            txtDataPgt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("  /  /    ")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtDataPgt.setText("");
        txtDataVencimento.setText("");
        try {
            txtDataVencimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
            txtDataPgt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
    }

    public void atualizarTabela() {
        tabelaItens.setModel(new ModeloItens(itens));
        resetarVariaveis();
        atualizarValorTotal();
        btnRemover.setEnabled(false);
        btnEditar.setEnabled(false);
    }

    public void atualizarValorTotal() {
        double valorParcial = 0;
        for (int i = 0; i < itens.size(); i++) {
            valorParcial = valorParcial + itens.get(i).getValorIten();
        }
        valorTotal = valorParcial;
        txtValorTotal.setText(new Moeda(valorTotal).toString());
    }

    private class ModeloItens extends DefaultTableModel {

        private List<ItemSaida> lista;
        private String[] campos = new String[]{"Id", "Centro Custo", "Vencimento", "Pagamento", "Valor"};

        public ModeloItens(List<ItemSaida> list) {
            lista = list;
        }

        public ModeloItens() {
        }

        public ItemSaida getItemSaida(int index) {
            return lista.get(index);
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }

        @Override
        public Object getValueAt(int row, int column) {
            ItemSaida item = lista.get(row);


            switch (column) {
                case 0:
                    return row + 1;

                case 1:
                    return item.getCentroCusto().getDescricao();

                case 2:
                    if (item.getDataVencimento() != null) {
                        return new Data().ConverteDataDateStringBra(item.getDataVencimento());
                    } else {
                        return "--";
                    }

                case 3:
                    if (item.getDataPgt() != null) {
                        return new Data().ConverteDataDateStringBra(item.getDataPgt());
                    } else {
                        return "--";
                    }

                case 4:
                    return new Moeda(item.getValorIten()).toString();

                default:
                    return null;
            }
        }

        @Override
        public int getRowCount() {
            return lista == null ? 0 : lista.size();
        }

        @Override
        public int getColumnCount() {
            return campos.length;
        }

        @Override
        public String getColumnName(int column) {
            return campos[column];
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        painelEditar = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabelaItens = new javax.swing.JTable();
        jLabel10 = new javax.swing.JLabel();
        btnRemover = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        btnAdicionar = new javax.swing.JButton();
        txtValor = new javax.swing.JFormattedTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtDataVencimento = new javax.swing.JFormattedTextField();
        txtDataPgt = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        comboCentroCusto = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtData = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtNumero = new javax.swing.JTextField();
        txtDeposito = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        comboTipoSaida = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtObservacao = new javax.swing.JTextArea();
        jLabel7 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        btnLancar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnConfirmar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnEstornar = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        btnCancelar = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        jLabel4 = new javax.swing.JLabel();
        txtSituacao = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtValorTotal = new javax.swing.JFormattedTextField();
        painelInformacoes = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        txtDataLancamento = new javax.swing.JFormattedTextField();
        txtDataConfirmacao = new javax.swing.JFormattedTextField();
        txtDataCancelamento = new javax.swing.JFormattedTextField();
        jLabel17 = new javax.swing.JLabel();
        txtLancamentoPor = new javax.swing.JTextField();
        txtConfirmadoPor = new javax.swing.JTextField();
        txtCanceladoPor = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        txtDataEstorno = new javax.swing.JFormattedTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        txtEstornadoPor = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(asfabdesk.apresentacao.AsfabDeskApp.class).getContext().getResourceMap(TelaFinSaida.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        painelEditar.setName("painelEditar"); // NOI18N
        painelEditar.setOpaque(false);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setOpaque(false);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tabelaItens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "Centro Custo", "Vencimento", "Pagamento", "Valor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaItens.setName("tabelaItens"); // NOI18N
        tabelaItens.setOpaque(false);
        tabelaItens.setSelectionBackground(resourceMap.getColor("tabelaItens.selectionBackground")); // NOI18N
        tabelaItens.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tabelaItens.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaItensMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tabelaItens);
        tabelaItens.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tabelaItens.columnModel.title0")); // NOI18N
        tabelaItens.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tabelaItens.columnModel.title1")); // NOI18N
        tabelaItens.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tabelaItens.columnModel.title2")); // NOI18N
        tabelaItens.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tabelaItens.columnModel.title4")); // NOI18N
        tabelaItens.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("tabelaItens.columnModel.title3")); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        btnRemover.setIcon(resourceMap.getIcon("btnRemover.icon")); // NOI18N
        btnRemover.setEnabled(false);
        btnRemover.setName("btnRemover"); // NOI18N
        btnRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverActionPerformed(evt);
            }
        });

        btnEditar.setIcon(resourceMap.getIcon("btnEditar.icon")); // NOI18N
        btnEditar.setEnabled(false);
        btnEditar.setName("btnEditar"); // NOI18N
        btnEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarActionPerformed(evt);
            }
        });

        btnAdicionar.setIcon(resourceMap.getIcon("btnAdicionar.icon")); // NOI18N
        btnAdicionar.setEnabled(false);
        btnAdicionar.setName("btnAdicionar"); // NOI18N
        btnAdicionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdicionarActionPerformed(evt);
            }
        });

        txtValor.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###,###,##0.00"))));
        txtValor.setName("txtValor"); // NOI18N

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        try {
            txtDataVencimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtDataVencimento.setName("txtDataVencimento"); // NOI18N

        try {
            txtDataPgt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtDataPgt.setName("txtDataPgt"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        comboCentroCusto.setName("comboCentroCusto"); // NOI18N
        comboCentroCusto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboCentroCustoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboCentroCusto, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDataVencimento, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addGap(3, 3, 3)
                        .addComponent(txtDataPgt, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel24)
                        .addGap(7, 7, 7)
                        .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnAdicionar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap(679, Short.MAX_VALUE)
                        .addComponent(btnEditar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemover)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboCentroCusto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAdicionar, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtDataVencimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDataPgt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRemover)
                    .addComponent(btnEditar))
                .addContainerGap())
        );

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setOpaque(false);

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        try {
            txtData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtData.setName("txtData"); // NOI18N
        txtData.setOpaque(false);

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel9.setName("jLabel9"); // NOI18N

        txtNumero.setEditable(false);
        txtNumero.setName("txtNumero"); // NOI18N
        txtNumero.setOpaque(false);

        txtDeposito.setEditable(false);
        txtDeposito.setName("txtDeposito"); // NOI18N
        txtDeposito.setOpaque(false);

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        comboTipoSaida.setName("comboTipoSaida"); // NOI18N
        comboTipoSaida.setOpaque(false);
        comboTipoSaida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboTipoSaidaActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txtObservacao.setColumns(20);
        txtObservacao.setRows(5);
        txtObservacao.setBorder(null);
        txtObservacao.setName("txtObservacao"); // NOI18N
        jScrollPane1.setViewportView(txtObservacao);

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 793, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2)
                        .addGap(3, 3, 3)
                        .addComponent(txtData, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboTipoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDeposito, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE))
                    .addComponent(jLabel7))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(comboTipoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDeposito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(jLabel9))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(10, Short.MAX_VALUE))
        );

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setOpaque(false);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N
        jToolBar1.setOpaque(false);

        jSeparator4.setName("jSeparator4"); // NOI18N
        jToolBar1.add(jSeparator4);

        btnLancar.setIcon(resourceMap.getIcon("btnLancar.icon")); // NOI18N
        btnLancar.setToolTipText(resourceMap.getString("btnLancar.toolTipText")); // NOI18N
        btnLancar.setName("btnLancar"); // NOI18N
        btnLancar.setOpaque(false);
        btnLancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLancarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnLancar);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        btnConfirmar.setIcon(resourceMap.getIcon("btnConfirmar.icon")); // NOI18N
        btnConfirmar.setToolTipText(resourceMap.getString("btnConfirmar.toolTipText")); // NOI18N
        btnConfirmar.setEnabled(false);
        btnConfirmar.setName("btnConfirmar"); // NOI18N
        btnConfirmar.setOpaque(false);
        btnConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfirmarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnConfirmar);

        jSeparator3.setName("jSeparator3"); // NOI18N
        jToolBar1.add(jSeparator3);

        btnEstornar.setIcon(resourceMap.getIcon("btnEstornar.icon")); // NOI18N
        btnEstornar.setToolTipText(resourceMap.getString("btnEstornar.toolTipText")); // NOI18N
        btnEstornar.setEnabled(false);
        btnEstornar.setFocusable(false);
        btnEstornar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEstornar.setName("btnEstornar"); // NOI18N
        btnEstornar.setOpaque(false);
        btnEstornar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEstornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEstornarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnEstornar);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        btnCancelar.setIcon(resourceMap.getIcon("btnCancelar.icon")); // NOI18N
        btnCancelar.setToolTipText(resourceMap.getString("btnCancelar.toolTipText")); // NOI18N
        btnCancelar.setEnabled(false);
        btnCancelar.setName("btnCancelar"); // NOI18N
        btnCancelar.setOpaque(false);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnCancelar);

        jSeparator5.setName("jSeparator5"); // NOI18N
        jToolBar1.add(jSeparator5);

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        txtSituacao.setEditable(false);
        txtSituacao.setName("txtSituacao"); // NOI18N
        txtSituacao.setOpaque(false);

        jLabel11.setFont(resourceMap.getFont("jLabel11.font")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        txtValorTotal.setBorder(null);
        txtValorTotal.setEditable(false);
        txtValorTotal.setFont(resourceMap.getFont("txtValorTotal.font")); // NOI18N
        txtValorTotal.setName("txtValorTotal"); // NOI18N
        txtValorTotal.setOpaque(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 173, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(5, 5, 5)
                .addComponent(txtSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtValorTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtValorTotal)
                            .addComponent(jLabel11))
                        .addGap(22, 22, 22))))
        );

        javax.swing.GroupLayout painelEditarLayout = new javax.swing.GroupLayout(painelEditar);
        painelEditar.setLayout(painelEditarLayout);
        painelEditarLayout.setHorizontalGroup(
            painelEditarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelEditarLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(painelEditarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        painelEditarLayout.setVerticalGroup(
            painelEditarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelEditarLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("painelEditar.TabConstraints.tabTitle"), painelEditar); // NOI18N

        painelInformacoes.setName("painelInformacoes"); // NOI18N
        painelInformacoes.setOpaque(false);

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setOpaque(false);

        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        txtDataLancamento.setEditable(false);
        txtDataLancamento.setName("txtDataLancamento"); // NOI18N
        txtDataLancamento.setOpaque(false);

        txtDataConfirmacao.setEditable(false);
        txtDataConfirmacao.setName("txtDataConfirmacao"); // NOI18N
        txtDataConfirmacao.setOpaque(false);

        txtDataCancelamento.setEditable(false);
        txtDataCancelamento.setName("txtDataCancelamento"); // NOI18N
        txtDataCancelamento.setOpaque(false);

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        txtLancamentoPor.setEditable(false);
        txtLancamentoPor.setName("txtLancamentoPor"); // NOI18N
        txtLancamentoPor.setOpaque(false);

        txtConfirmadoPor.setEditable(false);
        txtConfirmadoPor.setName("txtConfirmadoPor"); // NOI18N
        txtConfirmadoPor.setOpaque(false);

        txtCanceladoPor.setEditable(false);
        txtCanceladoPor.setName("txtCanceladoPor"); // NOI18N
        txtCanceladoPor.setOpaque(false);

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N

        txtDataEstorno.setEditable(false);
        txtDataEstorno.setName("txtDataEstorno"); // NOI18N
        txtDataEstorno.setOpaque(false);

        jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N

        txtEstornadoPor.setEditable(false);
        txtEstornadoPor.setName("txtEstornadoPor"); // NOI18N
        txtEstornadoPor.setOpaque(false);

        jLabel8.setName("jLabel8"); // NOI18N

        jLabel12.setName("jLabel12"); // NOI18N

        jLabel13.setName("jLabel13"); // NOI18N

        jLabel14.setName("jLabel14"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(txtLancamentoPor, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(txtDataConfirmacao, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(txtConfirmadoPor, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(jLabel13)
                    .addComponent(txtDataCancelamento, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20)
                    .addComponent(txtCanceladoPor, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(jLabel14)
                    .addComponent(jLabel23)
                    .addComponent(txtDataEstorno, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(txtEstornadoPor, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(477, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtLancamentoPor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataConfirmacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtConfirmadoPor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataCancelamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtCanceladoPor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataEstorno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel25)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtEstornadoPor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout painelInformacoesLayout = new javax.swing.GroupLayout(painelInformacoes);
        painelInformacoes.setLayout(painelInformacoesLayout);
        painelInformacoesLayout.setHorizontalGroup(
            painelInformacoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelInformacoesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        painelInformacoesLayout.setVerticalGroup(
            painelInformacoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelInformacoesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("painelInformacoes.TabConstraints.tabTitle"), painelInformacoes); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 822, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tabelaItensMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaItensMouseClicked
        btnEditar.setEnabled(true);
        btnRemover.setEnabled(true);
}//GEN-LAST:event_tabelaItensMouseClicked

    private void btnRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverActionPerformed
        removerItem();
}//GEN-LAST:event_btnRemoverActionPerformed

    private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
        editarItem();
}//GEN-LAST:event_btnEditarActionPerformed

    private void btnAdicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdicionarActionPerformed
        adicionarItem();
}//GEN-LAST:event_btnAdicionarActionPerformed

    private void btnLancarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLancarActionPerformed
        lancarSaida();
}//GEN-LAST:event_btnLancarActionPerformed

    private void btnConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmarActionPerformed
        confirmarSaida();
}//GEN-LAST:event_btnConfirmarActionPerformed

    private void btnEstornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEstornarActionPerformed
        int resp = JOptionPane.showConfirmDialog(null, "Realmente deseja estornar a Saída " + saida.getId() + " ?", "Estornar ?", 0);
        if (resp == 0) {
            estornarSaida();
        }
}//GEN-LAST:event_btnEstornarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        int resp = JOptionPane.showConfirmDialog(null, "Realmente deseja Cancelar a Saída " + saida.getId() + " ?" + "\n" + "Não será possível reverter este procedimento. " + "\n" + "Confirma ?", "Estornar ?", 0);
        if (resp == 0) {
            cancelarSaida();
        }
}//GEN-LAST:event_btnCancelarActionPerformed

    private void comboCentroCustoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCentroCustoActionPerformed
}//GEN-LAST:event_comboCentroCustoActionPerformed

    private void comboTipoSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTipoSaidaActionPerformed
        try {
            acaoComboTipoSaida();
        } catch (SQLException ex) {
            Logger.getLogger(TelaFinSaida.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_comboTipoSaidaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdicionar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConfirmar;
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnEstornar;
    private javax.swing.JButton btnLancar;
    private javax.swing.JButton btnRemover;
    private javax.swing.JComboBox comboCentroCusto;
    private javax.swing.JComboBox comboTipoSaida;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel painelEditar;
    private javax.swing.JPanel painelInformacoes;
    private javax.swing.JTable tabelaItens;
    private javax.swing.JTextField txtCanceladoPor;
    private javax.swing.JTextField txtConfirmadoPor;
    private javax.swing.JFormattedTextField txtData;
    private javax.swing.JFormattedTextField txtDataCancelamento;
    private javax.swing.JFormattedTextField txtDataConfirmacao;
    private javax.swing.JFormattedTextField txtDataEstorno;
    private javax.swing.JFormattedTextField txtDataLancamento;
    private javax.swing.JFormattedTextField txtDataPgt;
    private javax.swing.JFormattedTextField txtDataVencimento;
    private javax.swing.JTextField txtDeposito;
    private javax.swing.JTextField txtEstornadoPor;
    private javax.swing.JTextField txtLancamentoPor;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextArea txtObservacao;
    private javax.swing.JTextField txtSituacao;
    private javax.swing.JFormattedTextField txtValor;
    private javax.swing.JFormattedTextField txtValorTotal;
    // End of variables declaration//GEN-END:variables
}
